<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class sfTableFormFilter extends sfTableBaseFormFilter
{
    
  public function addDatosAfiliadoQuery (Doctrine_Query $query, $field, $values){
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    if($values['text'] == ''){
        return;
    }
    $arreglo = explode(" ",$values['text']);

    foreach($arreglo as $palabra)
    {
            if(is_numeric($palabra))
            {
                $parte = sprintf('(%s LIKE ?) Or (%s = ?)', $this->filterFields['afiliado'], $this->filterFields['docNumero']);
                $parametros = array($palabra.'%',$palabra);
            }else
            {
                $parte = sprintf('(%s LIKE ?)', $this->filterFields['nombreCompuesto']);
                $parametros ='%'.addcslashes($palabra, '\'\%_').'%';
            }

            $query->andWhere($parte,$parametros);
            
            $this->parent->thSchema[$field]->setFilter();            

    }

  }
    
    
}




?>
